package com.quanquan.store.repository.marketActivity.turnTable;

import com.quanquan.store.entity.marketActivity.turnTable.TurnTableRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @ClassName TurnTableRecordRepository
 * @Description
 * @Author Owen
 * @Date 2019/9/19 0019 上午 10:37
 * @Version V1.0
 **/
public interface TurnTableRecordRepository extends JpaRepository<TurnTableRecord,Integer>, JpaSpecificationExecutor<TurnTableRecord> {

    @Query(value = "select * from oo_turn_table_record where activity_id=?1 and activity_type=?2 and gift_type > 0 order by create_time desc limit ?3,?4",nativeQuery = true)
    List<TurnTableRecord> findAllRecords(Long activityId, Integer activityType, Integer limit, Integer size);

    @Query(value = "select * from oo_turn_table_record where activity_id=?1 and activity_type=1 group by user_id",nativeQuery = true)
    List<TurnTableRecord> findDistinctByUserIdAndActivityId(Long activityId);
}
